const { Sequelize } = require("sequelize")
const db = new Sequelize(
  config.db.database,
  config.db.username,
  config.db.password,
  {
    host: config.db.host,
    dialect: "mysql",
    dialectOptions: {
      charset: 'utf8mb4',
      dateStrings: true,
      typeCast: (field, next) => { // for reading from database
        if (field.type === 'DATETIME') {
          return field.string()
        }
        return next()
      },
    },
    timezone: "+08:00",
    define: {
      freezeTableName: true, //Model名与表名相同
    },
    logging: false,
  }
)
module.exports = db;



